package com.linux.huhx.thread2;

import java.util.concurrent.*;

public class ExecutorServiceTest {
    public static void main(String[] args) throws Exception {
        ExecutorService service = Executors.newSingleThreadExecutor();
        Future<String> future = service.submit(new Callable<String>() {

            @Override
            public String call() throws Exception {
                TimeUnit.SECONDS.sleep(5);
                return "string " + System.currentTimeMillis();
            }
        });

        System.out.println(future.get());
        service.shutdown();
        System.out.println("future的get()方法是阻塞的。");
    }
}
